<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h3>h3</h3>
    <input type="text" name="hehe">
    <input type="text">
    <input type="text">
    <div id="box" name="hehe" index="0"></div>
</body>
</html>
<script>
    var allTag=document.getElementsByTagName("*");
    var names=[];
    function myName(val){
        for(var i=0;i<allTag.length;i++){
            var item=allTag[i];
            if(item.name=="hehe"){
                names.push(item);
            }
        }
        return names;
    }
    var res=myName("hehe");
</script>